<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * Created by PhpStorm.
 * User: 修
 * Date: 2015/2/14
 * Time: 18:54
 */
class Article extends CI_Controller{
    function __construct(){
        parent::__construct();
        $this->load->model("model_article");
    }
    function all(){
        if($_POST)
            echo json_encode($this->model_article->all("where content like \"%".$_POST["condition"]."%\" "));
        else
            echo json_encode($this->model_article->all());
    }
    function add(){
        $content = $_POST["content"];
        @$author = $_SESSION["user"]["uid"];
        echo $this->model_article->add($content,$author);
    }
    function praise($aid){
        echo $this->model_article->praise($aid);
    }
    function nay($aid){
        echo $this->model_article->nay($aid);
    }
    function comment($aid){
        echo $this->model_article->comment($aid,$_POST["comment"]);
    }
}